//
//  ViewController.m
//  Wsj2017_构建者模式_1
//
//  Created by macOS on 2017/4/21.
//  Copyright © 2017年 macOS. All rights reserved.
//

#import "ViewController.h"
#import "Direct.h"
#import "LennoverComputerBuilder.h"
@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view, typically from a nib.
    
    
    [self test];
}




- (void)test{

   // 将构建层 和显示层 分开
    
    
    //角色一: IProduct (抽象产品类: 协议)
    //角色二: ConcrateProduct (具体产品类 : 实现了IProduct的协议)
    //角色三:IBuilder(抽象构建者: 协议)
    //角色四:ConcreteBuilder (具体的构建者: 实现IBuilder的协议)
    //角色五:统一组装类(可有可无)
    
    
//   Direct *d =  [[Direct alloc] init];
//    
//    [d wsj_builder:^(id<IComputerBuilder> builder) {
//        [builder builderCPU:@"inter CPU"];
//        
//        [builder builderDisplay:@"三星 显示器"];
//        
//        
//    }];
//    
    
    //第一种写法
//    id<IComputerBuilder> builder = [[LennoverComputerBuilder alloc] init];
//    
//    Direct *direct = [[Direct alloc] initWithBuilder:builder];
//    
//    [direct constructCPU:@"Inter i7 " mianboard:@"三星显示器"];
    
    
    //第二种写法(经常看到)
    
    id<IComputerBuilder> builder2 = [[LennoverComputerBuilder alloc] init];
    [[[builder2 builderCPU:@"Inter i7 " ] builderDisplay:@"惠普显示器"] builder];
    
    

}


@end
